<template>
  <div class="equipment-left">
    <div class="top-tab">
      <el-carousel
        :autoplay="false"
        :loop="false"
        arrow="always"
        trigger="click"
      >
        <el-carousel-item
          v-for="item in 5"
          :key="item"
          style="display: flex;gap: 8px"
        >
          <div
            v-for="(val, i) in tabList"
            :key="i"
            :class="['tab-item' , val.type === current ? 'active' : '']"
            style="display: flex"
            @click="tabChange(val)"
          >
            <div :class="['text' , val.type === current ? 'active' : '']">{{ val.name }}</div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="chart-box-con">
      <div v-for="(item,i) in 5" :key="item" :class="['card-item', cardCurrent===i ? 'active' : '']"
           @click="changeCard(i)">
        <div class="card-top">
          <div class="img">
            <img :src="getDeviceImg(i+1)" alt="">
          </div>
          <div class="card-name">
            <div>
              <div class="name">叉车1</div>
              <div class="status">运行中</div>
            </div>
            <div>
              <div>电量</div>
              <el-progress class="progress" :percentage="50" :show-text="false" color="#46BFEA" define-back-color="#284d5b"></el-progress>
            </div>
          </div>
        </div>
        <div class="card-bottom">
          <div><span>运行时间</span><span>545641</span></div>
          <div><span>额定功率</span><span>545641W</span></div>
          <div><span>功率消耗</span><span>1235W</span></div>
          <div><span>温度</span><span>60℃</span></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>

import {getDeviceImg} from '@/views/equipmentScreen/hooks'

export default {
  name: "equipmentLeft",
  components: {},
  data () {
    return {
      tabList: [
        {
          name: '灌装设备',
          type: "1"
        },
        {
          name: '灌装设备',
          type: "2"
        },
        {
          name: '充装设备',
          type: "3"
        },
        {
          name: '包装设备',
          type: "4"
        },
        {
          name: '堆码设备',
          type: "5"
        },
      ],
      current: '1',
      cardCurrent: 0
    }
  },
  methods: {
    getDeviceImg,
    changeSelectType (type) {
      this.current = type
    },
    changeCard (item) {
      if(item===this.cardCurrent){
        this.cardCurrent=''
      }else{
        this.cardCurrent = item
      }

    },
    tabChange (val) {
      this.current = val.type
    }
  }
}
</script>
<style lang="scss" scoped>
$root-font-size: 106.6px;
@function px-to-rem($px) {
  @return ($px / $root-font-size) * 1rem;
}

.equipment-left {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  .top-tab {
    height: px-to-rem(60px);

    .tab-item {
      width: px-to-rem(70px);
      cursor: pointer;
      //background: url("../images/tab.png") no-repeat;
      background-size: 100%;
      position: relative;
      &.active {
        height: 100%;
        &:after{
          position: absolute;
          bottom: -5px;
          width: 100%;
          height: 100%;
          content: "";
          background: url("../images/tab-bottom.png") no-repeat;
          background-size: 100%;
        }
      }

      .text {
        width: 100%;
        height: px-to-rem(34px);
        line-height: px-to-rem(34px);
        text-align: center;
        margin-top: px-to-rem(8px);
        color: #2786E3;
        font-size: px-to-rem(11.5px);
        padding: 0 px-to-rem(8px);
        box-shadow: inset 0 0 px-to-rem(8px) px-to-rem(6px) #1f5e9f;

        &.active {
          color: #46BFEA;
          border-radius: 2px;
          box-shadow: inset 0 0 px-to-rem(6px) px-to-rem(3px) #46BFEA;
        }
      }
    }

  }

  .chart-box-con {
    flex: 1;
    height: px-to-rem(400px);
    //border: 1px solid red;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }

    .card-item {
      color: #fff;
      //min-height: px-to-rem(239px);
      min-height: 33.33%;
      //min-height: calc(100% / 3);
      background: url("../images/card-border.png") no-repeat;
      background-size: 100% 100%;
      padding: px-to-rem(20px)  px-to-rem(40px);
      display: flex;
      flex-direction: column;
      &.active {
        background: url("../images/card-border-active.png") no-repeat;
        background-size: 100% 100%;
      }
      .card-top{
        height: 35%;
        display: flex;
        justify-content: space-between;
        margin-bottom: px-to-rem(15px);
        font-size: px-to-rem(13px);
        gap: px-to-rem(20px);
        .img{
          width: px-to-rem(74px);
          height: 100%;
          text-align: center;
          img{
            height: 100%;
          }
        }
        .card-name{
          flex: 1;
          display: flex;
          flex-direction: column;
          align-items: center;
          width: 60%;
          >div{
            width: 100%;
            flex: 1;
            display: flex;
            align-items: center;
            gap: px-to-rem(20px);
            .name{
              font-size: px-to-rem(17px);
            }
            .status{
              margin-left: auto;
              color: #46BFEA;
              position:relative;
              &:before{
                content: "";
                width: px-to-rem(4px);
                height: px-to-rem(4px);
                border-radius: 50%;
                background: #46BFEA;
                position: absolute;
                top: px-to-rem(8px);
                left: px-to-rem(-10px);
              }
            }
            .progress{
              flex: 1;
              width: auto;
            }
          }
        }
      }
      .card-bottom{
        flex: 1;
        padding: 0 px-to-rem(35px);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-content: space-between;
        font-size: px-to-rem(13px);
        >div{
          display: flex;
          justify-content: space-between;
        }
      }
    }
  }

  /deep/ .el-carousel {
    height: 100%;
  }

  /deep/ .el-carousel__container {
    height: 100%;
  }

  /deep/ .el-carousel__indicators {
    display: none;
  }

  /deep/ .el-carousel__item {
    padding: 0 px-to-rem(32px);
    //overflow: hidden;
  }

  /deep/ .el-carousel__arrow {
    background-color: rgba(255, 255, 255, 0.25);
    width: px-to-rem(22px);
    height: px-to-rem(22px);
    top: 60%;
  }

  /deep/ .el-carousel__arrow--left {
    left: 0;
  }

  /deep/ .el-carousel__arrow--right {
    right: 0;
  }
}
</style>